package com.book.util;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Author LiJinCheng
 * @Date 2020/11/17 4:55 下午
 * @Version 1.0
 * @package com.book.util
 **/
public class RandomUtil {
    @Resource
    private static RedisUtil redisUtil;

    public static String updateBookKey() {
        if (!redisUtil.exists(Constants.BOOK_KEY)) {
            redisUtil.set(Constants.BOOK_KEY, BOOK_KEY());
        }
        String key = redisUtil.get(Constants.BOOK_KEY);
        redisUtil.set(Constants.BOOK_KEY, BOOK_KEY());
        return key;
    }

    public static String BOOK_KEY() {
        return UUID.randomUUID().toString();
    }

}
